<?php
namespace App\Http\Controllers\Open;
use App\Facades\Site;
use App\Http\Controllers\Common\CommonController;
use App\Models\Company\CompanyBasic;
use App\Repositories\Eloquent\YiwangAccessToken;

class ResumeSearchController extends CommonController{

    public function index(){
        $user = auth()->guard('company')->user();

        $vip='';//是否会员，1为会员
        if(!empty($user->uid)){
            $companyBasic = CompanyBasic::where('uid', $user->uid)->orderBy('updatetime', 'desc')->first();

            if($user->viptime>=date('Y-m-d H:i:s')){
                $vip=1;
            }
        }
        $yiwangAccessToken = new YiwangAccessToken();
        $accessToken=$yiwangAccessToken->getAccessToken();
        $data=array(
            'unionid'=>Site::get('yiwang_unionid'),
            'clientid'=>(!empty($companyBasic->id) && $vip==1)?$companyBasic->id:0,
            'access_token'=>$accessToken
        );

        $json=$yiwangAccessToken->curlPost("https://www.1wyun.com/get_resume_url",$data);
        $json=json_decode($json);
        if(!empty($json->url)){
            return redirect($json->url);
        }else{
            echo "链接平台失败或错误的参数!";
        }


    }
}

